package com.jay.syncdrawing.ui;

import com.jay.syncdrawing.AppManager;
import com.jay.syncdrawing.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

public class WelcomActivity extends Activity {
	private View view;
	private Intent intent = new Intent();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AppManager.getAppManager().addActivity(this);
		
		view = View.inflate(this, R.layout.activity_welcom, null);
		setContentView(view);
		//设置动画
		setAnimation();
	}
	
	private void setAnimation() {
		//透明度动画
		AlphaAnimation alphaAnim = new AlphaAnimation(0.3f, 1.0f);
		alphaAnim.setDuration(2000);
		view.startAnimation(alphaAnim);
		alphaAnim.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationRepeat(Animation arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationEnd(Animation arg0) {
				startApp();
			}
		});
	}
	
	private void startApp(){
		intent.setClass(WelcomActivity.this, ServerActivity.class);
		startActivity(intent);
		finish();
	}
}
